<template>
  <div id="effect-login-window">
    <div class="block-1">
      <div class="one-block-2">
        <a-row :gutter="[16, 32]">
          <a-col :span="20" :offset="2">
            <a-input
              v-model:value="keyCode"
              placeholder="请输入秘钥"
              addon-before="秘钥"
            />
          </a-col>

          <a-col :span="8">
            <a @click="loginout">
              <a-button> 退出 </a-button>
            </a>
          </a-col>

          <a-col :span="8">
            <a @click="login">
              <a-button> 登录 </a-button>
            </a>
          </a-col>
        </a-row>
      </div>
    </div>
  </div>
</template>
<script>
// import { Library } from "ffi-napi";
// import path from 'path'
// const { machineId, machineIdSync } = require('node-machine-id')
export default {
  data() {
    return {
      loading: false,
      keyCode: null
    }
  },
  created() {
    // ipc
    //   .invoke(ipcApiRoute.restoreWindow, { width: 500, height: 400 })
    //   .then((r) => {})
    // var uuid = JSON.stringify(machineIdSync({ original: true }))
    // console.log('UUID:', uuid,machineId)
  },
  methods: {
    login() {
      // const dlltest =
      //   'C:/company project/dataPurge/dataPurge-PXE-Server/src/lib/AxInterop.EstampOcxLib.dll'
      // const filePathTest = path.resolve(dlltest)
      // let libExportTest = Library(filePathTest, {
      //   sum: ['int', ['int', 'int']]
      // })
      // const result = libExportTest.sum(1, 2)
      // console.log(result, '??')
      if (this.keyCode) {
      } else {
        this.$message.error('请输入秘钥！')
        return
      }
      this.loading = true
      // const decodeJwt = require('jwt-decode')
      // console.log(decodeJwt,'decodeJwt');
      // const decoded = decodeJwt.jwtDecode(this.keyCode);
      // console.log(decoded, '解析后的jwt');
      // localStorage.setItem('keyCode', this.keyCode)
      var fullUrl = window.location.href
      var local = fullUrl.slice(0, fullUrl.indexOf('#'))
      window.location.href = local + `#/welll`
      // ipc
      //   .invoke(ipcApiRoute.restoreWindow, { width: 1374, height: 945 })
      //   .then((r) => {})
    },
    loginout() {
      // ipc.invoke(ipcApiRoute.loginout, {}).then((res) => {
      //   console.log(res)
      // })
    }
  }
}
</script>
<style>
#effect-login-window {
  width: 100%;
  min-height: 100%;
  background: #f0f2f5 url(/src/assets/login.png) no-repeat 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#effect-login-window .block-1 {
  font-size: 16px;
  align-items: center;
  margin: auto;
  display: inline-block;
}
</style>
